#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

const int maxn=10, maxm=1000, mods=1000000007;
const char ele[]="ACGT";

int max(int a, int b) {
	return a>b ? a : b;
}

int main() {
#ifdef DEBUG
	freopen("src.in", "r", stdin);
	freopen("src.out", "w", stdout);
#endif

	static char s[maxn+2];
	int n, m;
	scanf("%s %d", s+1, &m);
	n = strlen(s+1);

	static ll f[maxm+1][1<<maxn], g[maxn+1], ng[maxn+1];
	f[0][0] = 1;
	for (int i=0; i<m; i++) {
		for (int x=0; x<(1<<n); x++) {
			for (int j=1; j<=n; j++) {
				g[j] = g[j-1]+((x>>(j-1))&1);
			}
			for (int j=0; j<4; j++) {
				for (int k=1; k<=n; k++) {
					ng[k] = max(ng[k-1], g[k]);
					if (ele[j]==s[k]) {
						ng[k] = max(ng[k], g[k-1]+1);
					}
				}
				int nx=0;
				for (int k=1; k<=n; k++) {
					nx |= (ng[k]-ng[k-1])<<(k-1);
				}
				f[i+1][nx] = (f[i+1][nx]+f[i][x])%mods;
			}
		}
	}

	static ll ans[maxn+1];
	for (int i=0; i<(1<<n); i++) {
		int cnt=0;
		for (int j=1; j<=n; j++) {
			cnt += (i>>(j-1))&1;
		}
		ans[cnt] = (ans[cnt]+f[m][i])%mods;
	}
	for (int i=0; i<=n; i++) {
		printf("%lld\n", ans[i]);
	}

	fclose(stdin);
	fclose(stdout);
	return 0;
}
